package com.dankegongyu.demo.http.http;

import java.io.Serializable;

/**
 * 网络请求错误信息
 *
 * @author wpq
 * @version 1.0
 */
public class HttpError implements Serializable {
    private static final long serialVersionUID = 8508604845885256823L;

//    {
//        "message":"Validation Failed",
//        "description":"密码太简单，请根据输入框下提示使用安全密码",
//        "businessCode":"10002000",
//        "errors":[]
//    }

    public static final String ERROR_CODE_DEFAULT = "-1";
    public static final int NETWORK_ERROR = 0;
    public static final int REQUEST_ERROR = 1;

    /**
     * 网络错误还是接口请求失败，这个字段是自己加的，为了区分网络错误和接口错误页面提示
     */
    public int type = REQUEST_ERROR;
    /**
     * 业务码
     */
    public String businessCode = ERROR_CODE_DEFAULT;
    public String description;
    public String message;
//    public List<?> errors; // 这个先不解了

    @Override
    public String toString() {
        return "HttpError{" +
                "type=" + type +
                ", businessCode=" + businessCode +
                ", description='" + description + '\'' +
                ", message='" + message + '\'' +
                '}';
    }

    /**
     * 请求失败是否是网络原因导致的
     */
    public boolean isNetworkError() {
        return type == NETWORK_ERROR;
    }
}
